package chen.jia.xin.finalproject.LogView;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.Timer;
import java.util.TimerTask;
import chen.jia.xin.finalproject.BaseActivity;
import chen.jia.xin.finalproject.MainView.MainActivity;
import chen.jia.xin.finalproject.R;

public class LoadinAnimation extends BaseActivity {

    ImageView imageView;
    TextView textView;
    Animation mAnimation;
    Timer timer;
    String userName;
    Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 1) {
                Intent intent = new Intent(LoadinAnimation.this, MainActivity.class);
                intent.putExtra("userName", userName);
                startActivity(intent);
            }
            super.handleMessage(msg);
        }
    };

    TimerTask task = new TimerTask() {
        @Override
        public void run() {
            // 需要做的事:发送消息
            Message message = new Message();
            message.what = 1;
            handler.sendMessage(message);
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.animationload);
        imageView = findViewById(R.id.animation_picture);
        mAnimation = AnimationUtils.loadAnimation(this, R.anim.loginanimation);
        imageView.startAnimation(mAnimation);
        textView = findViewById(R.id.load_notice);
        timer = new Timer();
        timer.schedule(task,3000);
        Intent intent = getIntent();
        userName = intent.getStringExtra("userName");
    }
}
